/**
 * StoreDBPrefs is a command line tool to encode the database connection preferences.
 * 
 * $Id: StoreDBPrefs.java,v 1.2 2006/09/15 14:23:24 jharlap Exp $
 */
package ca.mcgill.mni.bic;

import java.io.*;

/**
 * @author jharlap
 *
 */
public class StoreDBPrefs {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
		
		System.out.print("Passphrase: ");
		String passphrase = "";
		try {
			passphrase = console.readLine();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
        // Create encrypter/decrypter class
        Encrypter encrypter = new Encrypter(passphrase);
    
		String input = "";
		while(!input.equals("quit")) {
			System.out.print("Plaintext ('quit' to exit): ");
			try {
				input = console.readLine();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			String ciphertext = "";
			try {
		        // Encrypt the input
		        ciphertext = encrypter.encrypt(input);
		    } catch (Exception e) {
		    }

		    System.out.println("Ciphertext: '" + ciphertext + "'");
		}

	}
}
